﻿Imports System.Text
Module Module1
  Sub Main()

    Console.WriteLine("------------------------")
    Console.WriteLine(" Confronti tra stringhe ")
    Console.WriteLine("------------------------")

    Dim str1 As String = "prova"
    Dim str2 As String = "prova"

    If str1 = str2 Then
      Console.WriteLine(
        "str1 = str2  --> vero")
    Else
      Console.WriteLine(
        "str1 = str2  --> falso")
    End If

    If str1.Equals(str2) Then
      Console.WriteLine(
        "str1.Equals(str2)  --> vero")
    Else
      Console.WriteLine(
        "str1.Equals(str2)  --> falso")
    End If

    If String.ReferenceEquals(str1, str2) Then
      Console.WriteLine(
        "String.ReferenceEquals(str1, str2)  --> vero")
    Else
      Console.WriteLine(
        "String.ReferenceEquals(str1, str2)  --> falso")
    End If

    If str1.GetHashCode.ToString Is str2.GetHashCode.ToString Then
      Console.WriteLine(
        "str1 Is str2  --> vero")
    Else
      Console.WriteLine(
        "str1 Is str2  --> falso")
    End If

    Console.WriteLine()
    Console.WriteLine("-----------------------")
    Console.WriteLine(" Confronti tra oggetti")
    Console.WriteLine("-----------------------")

    Dim data1 As New Date(2010, 10, 31)
    Dim data2 As New Date(2010, 10, 31)

    If data1 = data2 Then
      Console.WriteLine(
        "data1 = data2  --> vero")
    Else
      Console.WriteLine(
        "data1 = data2  --> falso")
    End If

    If data1.Equals(data2) Then
      Console.WriteLine(
        "data1.Equals(data2)  --> vero")
    Else
      Console.WriteLine(
        "data1.Equals(data2)  --> falso")
    End If

    If String.ReferenceEquals(data1, data2) Then
      Console.WriteLine(
        "String.ReferenceEquals(data1, data2)  --> vero")
    Else
      Console.WriteLine(
        "String.ReferenceEquals(data1, data2)  --> falso")
    End If

    If data1.GetHashCode.ToString Is data2.GetHashCode.ToString Then
      Console.WriteLine(
        "data1 Is data2  --> vero")
    Else
      Console.WriteLine(
        "data1 Is data2  --> falso")
    End If

    Console.ReadLine()

  End Sub
End Module
